package com.yinhai.mycat_test.controller;

import java.util.ArrayList;
import java.util.List;

import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yinhai.mycat_test.entity.OrderItem;
import com.yinhai.mycat_test.mapper.write.OrderItemWriteMapper;

@RestController
@RequestMapping("/orderItem")
public class OrderItemController {
    
    @Autowired
    private OrderItemWriteMapper orderItemWriteMapper;
    
    @RequestMapping("/insert")
    public void insert(){
        OrderItem orderItem = new OrderItem();
        orderItem.setGoodsCount(1);
        orderItem.setGoodsName("item name:1");
        orderItem.setGoodsId(1L);
        orderItem.setOrderId(1L);
        orderItem.setGoodsPrice(10.0f);
        orderItem.setId(1L);
        orderItemWriteMapper.addOrderItem(orderItem);
    }
    
    @RequestMapping("/bacthInsert")
    public void insertBatch(){
        List<OrderItem> orderItemList = new ArrayList<>();
        for(int i = 0;i<10000;i++) {
            OrderItem orderItem = new OrderItem();
            orderItem.setGoodsCount(1);
            orderItem.setGoodsName("item name:1");
            orderItem.setGoodsId(1L);
            orderItem.setOrderId(1L);
            orderItem.setGoodsPrice(10.0f);
            orderItem.setId(Long.valueOf(i));
            orderItemList.add(orderItem);
        }
        orderItemWriteMapper.addListOrderItem(orderItemList);
    }

}
